/**************************************************************************************
*
*	Copyright (C) 2009 - 2012 Brent Andrew O. Chua - See LICENSE.txt for more info.
*		
*	Filename	-	Logic.cpp
*
*	Comments	-	See Logic.h
*
**************************************************************************************/

#include "../Include/Logic.h"
#include "../Include/View.h"

namespace Pulse
{
	Logic::Logic( void )
		: m_pProcessManager( PSX_NULL ), m_pApp( PSX_NULL )
	{

	}

	Logic::~Logic( void )
	{
		Shutdown();
	}

	EErrorCode::Type Logic::Initialize( Application *pApp )
	{
		if ( pApp == PSX_NULL )
		{
			PSX_PushError( "pAPp must be valid." );
			return EErrorCode::LOGIC;
		}

		m_pProcessManager = new ProcessManager;
		m_pApp = pApp;

		if ( m_pProcessManager == PSX_NULL )
			return EErrorCode::LOGIC;

		return OnInitialize();
	}

	void Logic::Shutdown( void )
	{
		PSX_SafeDelete( m_pProcessManager );
		OnShutdown();
	}

	void Logic::Update( DOUBLE time, FLOAT dt )
	{
		OnUpdate( time, dt );
	}

}